import { defineStore } from 'pinia'
export const useMainStore = defineStore('main', {
    // id:'main',//如果definePinia没有传入第一个参数name,而是直接传入一个对象，那么我们可以在这里设置id；是等价的
    state: () => ({ counter: 1 }),
})
export const useCounterStore = defineStore('counter', {
    state: () => ({ count: 1 }),
    getters: {
        double: (state) => state.count * 2,
    },
    actions: {
        increment() {
            this.count++
        },
    },
})
export const useLoginStore = defineStore({
    id: 'login',
    state: () => ({
      isLoggedIn: false,
      username: '',
    }),
    actions: {
      login(username) {
        this.isLoggedIn = true
        this.username = username
      },
      logout() {
        this.isLoggedIn = false
        this.username = ''
      },
    },
  })